package server

import (
	"enjoy_xxz/formdata"
	"enjoy_xxz/internal/model"
)

// 添加购物车
func CreateCart(data formdata.CreateCartReq, userID int64) error {
	ca := model.Cart{
		UserID:   userID,
		Quantity: data.Quantity,
		GoodsID:  data.GoodsId,
		SkuID:    data.SkuId,
	}
	return ca.CreateCart(data.Quantity)
}

// 购物车列表
func GetCartList(userID int64) ([]formdata.CartList, error) {
	ca := new(model.Cart)
	return ca.GetCartList(userID)

}

// 购物车修改
func CartUpdate(data formdata.CreateCartReq, userID int64) error {
	ca := model.Cart{
		Quantity: data.Quantity,
		SkuID:    data.SkuId,
	}
	return ca.CartUpdateByQuantity(userID)
}
